package com.sc.test.inputlowertoupper;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Toast;

import com.sc.test.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Shen Chao
 * Created by 2018-12-12
 */
public class InputLowerToUpperActivity extends AppCompatActivity {
    @BindView(R.id.et_input)
    EditText etInput;
    @BindView(R.id.checkbox)
    CheckBox checkbox;
    @BindView(R.id.btn)
    Button button;
    @BindView(R.id.show)
    Button show;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_input_lower_to_upper);
        ButterKnife.bind(this);

        checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    etInput.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                } else {
                    etInput.setTransformationMethod(PasswordTransformationMethod.getInstance());
                }
            }
        });
    }

    @OnClick({R.id.btn, R.id.show})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn:
                etInput.setTransformationMethod(new InputLowerToUpper());
                break;
            case R.id.show:
                Toast.makeText(this, etInput.getText().toString(), Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
